package com.wyzz.hr.io.extend;

import java.io.File;
import java.io.FileInputStream;
import java.util.List;

public abstract class IReadFileByImList {

	public IReadFileByImList(File inputFile, List imList, int hasTitle,
			IOMessages ioMessages) {
		setInputFile(inputFile);
		setImList(imList);
		setHasTitle(hasTitle);
		setIoMessages(ioMessages);
	}

	public List getContent() throws Exception {
		openFile();
		List result = readContent();
		closeFile();
		return result;
	}

	protected abstract List readContent();

	protected void openFile() throws Exception {
		inputStream = new FileInputStream(inputFile);
	}

	protected void closeFile() throws Exception {
		inputStream.close();
		inputStream = null;
	}

	public File getInputFile() {
		return inputFile;
	}

	public List getImList() {
		return imList;
	}

	public IOMessages getIoMessages() {
		return ioMessages;
	}

	public void setInputFile(File inputFile) {
		this.inputFile = inputFile;
	}

	public void setImList(List imList) {
		this.imList = imList;
	}

	public void setIoMessages(IOMessages ioMessages) {
		this.ioMessages = ioMessages;
	}

	public int getHasTitle() {
		return hasTitle;
	}

	public void setHasTitle(int hasTitle) {
		this.hasTitle = hasTitle;
	}

	protected File inputFile;
	protected List imList;
	protected IOMessages ioMessages;
	protected FileInputStream inputStream;
	protected int hasTitle;
}
